﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Data.Common;
using System.Data;


namespace System
{
    public interface IDalExecute
    {
        #region 基本方法
    
        /// <summary>
        /// 执行SQL语句，返回受影响的记录数
        /// </summary>
        /// <param name="commandText">SQL语句或存储过程名称</param>
        /// <returns>返回受影响的记录数</returns>
        int ExecuteNonQuery(string commandText);
        
        /// <summary>
        /// 执行SQL语句或存储过程，返回受影响的记录数
        /// </summary>
        /// <param name="commandText">SQL语句或存储过程名称</param>
        /// <param name="commandType">命令字符串类型</param>
        /// <returns>返回受影响的记录数</returns>
        int ExecuteNonQuery(string commandText, CommandType commandType);
        
        /// <summary>
        /// 执行SQL语句，返回受影响的记录数
        /// </summary>
        /// <param name="commandText">SQL语句或存储过程名称</param>
        /// <param name="parameters">参数集合</param>
        /// <returns>返回受影响的记录数</returns>
        int ExecuteNonQuery(string commandText, List<DbParameter> parameters);
        
        /// <summary>
        /// 执行SQL语句或存储过程，返回受影响的记录数
        /// </summary>
        /// <param name="commandText">SQL语句或存储过程名称</param>
        /// <param name="commandType">命令字符串类型</param>
        /// <param name="parameters">参数集合</param>
        /// <returns>返回受影响的记录数</returns>
        int ExecuteNonQuery(string commandText, CommandType commandType, List<DbParameter> parameters);
     
        /// <summary>
        /// 执行SQL语句，返回结果的第一行第一列
        /// </summary>
        /// <param name="commandText">SQL语句或存储过程名称</param>
        /// <returns>返回结果的第一行第一列</returns>
        object ExecuteScalar(string commandText);
        
        /// <summary>
        /// 执行SQL语句或存储过程，返回结果的第一行第一列
        /// </summary>
        /// <param name="commandText">SQL语句或存储过程名称</param>
        /// <param name="commandType">命令字符串类型</param>
        /// <returns>返回结果的第一行第一列</returns>
        object ExecuteScalar(string commandText, CommandType commandType);

        /// <summary>
        /// 执行SQL语句，返回结果的第一行第一列
        /// </summary>
        /// <param name="commandText">SQL语句或存储过程名称</param>
        /// <param name="parameters">参数集合</param>
        /// <returns>返回结果的第一行第一列</returns>
        object ExecuteScalar(string commandText, List<DbParameter> parameters);

        /// <summary>
        /// 执行SQL语句或存储过程，返回结果的第一行第一列
        /// </summary>
        /// <param name="commandText">SQL语句或存储过程名称</param>
        /// <param name="commandType">命令字符串类型</param>
        /// <param name="parameters">参数集合</param>
        /// <returns>返回结果的第一行第一列</returns>
        object ExecuteScalar(string commandText, CommandType commandType, List<DbParameter> parameters);
      
        /// <summary>
        /// 执行SQL语句,返回IDataReader
        /// </summary>
        /// <param name="commandText">SQL语句或存储过程名称</param>
        /// <returns>返回IDataReader</returns>
        IDataReader ExecuteReader(string commandText);
        
        /// <summary>
        /// 执行SQL语句或存储过程,返回IDataReader
        /// </summary>
        /// <param name="commandText">SQL语句或存储过程名称</param>
        /// <param name="commandType">命令字符串类型</param>
        /// <returns>返回IDataReader</returns>
        IDataReader ExecuteReader(string commandText, CommandType commandType);

        /// <summary>
        /// 执行SQL语句,返回IDataReader
        /// </summary>
        /// <param name="commandText">SQL语句或存储过程名称</param>
        /// <param name="parameters">参数集合</param>
        /// <returns>返回IDataReader</returns>
        IDataReader ExecuteReader(string commandText, List<DbParameter> parameters);

        /// <summary>
        /// 执行SQL语句或存储过程,返回IDataReader
        /// </summary>
        /// <param name="commandText">SQL语句或存储过程名称</param>
        /// <param name="commandType">命令字符串类型</param>
        /// <param name="parameters">参数集合</param>
        /// <returns>返回IDataReader</returns>
        IDataReader ExecuteReader(string commandText, CommandType commandType, List<DbParameter> parameters);
   
        /// <summary>
        /// 执行SQL语句,返回DataSet
        /// </summary>
        /// <param name="commandText">SQL语句或存储过程名称</param>
        /// <returns>返回DataSet</returns>
        DataSet ExecuteDataSet(string commandText);

        /// <summary>
        /// 执行SQL语句或存储过程,返回DataSet
        /// </summary>
        /// <param name="commandText">SQL语句或存储过程名称</param>
        /// <param name="commandType">命令字符串类型</param>
        /// <returns>返回DataSet</returns>
        DataSet ExecuteDataSet(string commandText, CommandType commandType);

        /// <summary>
        /// 执行SQL语句,返回DataSet
        /// </summary>
        /// <param name="commandText">SQL语句或存储过程名称</param>
        /// <param name="parameters">参数集合</param>
        /// <returns>返回DataSet</returns>
        DataSet ExecuteDataSet(string commandText, List<DbParameter> parameters);

        /// <summary>
        /// 执行SQL语句或存储过程,返回DataSet
        /// </summary>
        /// <param name="commandText">SQL语句或存储过程名称</param>
        /// <param name="commandType">命令字符串类型</param>
        /// <param name="parameters">参数集合</param>
        /// <returns>返回DataSet</returns>
        DataSet ExecuteDataSet(string commandText, CommandType commandType, List<DbParameter> parameters);

        #endregion

        #region 扩展方法

        /// <summary>
        /// 执行SQL语句或存储过程,返回受影响的记录数
        /// </summary>
        /// <param name="commandText">SQL语句或存储过程名称</param>
        /// <param name="parameters">参数集合</param>
        /// <param name="commandType">命令字符串类型</param>
        /// <returns>返回受影响的记录数</returns>
        int ExecuteNonQuery(string commandText, List<DBParameter> parameters, CommandType commandType);

        /// <summary>
        /// 执行SQL语句或存储过程,返回结果的第一行第一列的值
        /// </summary>
        /// <param name="commandText">SQL语句或存储过程名称</param>
        /// <param name="parameters">参数集合</param>
        /// <param name="commandType">命令字符串类型</param>
        /// <returns>返回结果的第一行第一列的值</returns>
        object ExecuteScalar(string commandText, List<DBParameter> parameters, CommandType commandType);

        /// <summary>
        /// 执行SQL语句或存储过程,返回IDataReader
        /// </summary>
        /// <param name="commandText">SQL语句或存储过程名称</param>
        /// <param name="parameters">参数集合</param>
        /// <param name="commandType">命令字符串类型</param>
        /// <returns>返回IDataReader</returns>
        IDataReader ExecuteReader(string commandText, List<DBParameter> parameters, CommandType commandType);

        /// <summary>
        /// 执行SQL语句或存储过程,返回DataSet
        /// </summary>
        /// <param name="commandText">SQL语句或存储过程名称</param>
        /// <param name="parameters">参数集合</param>
        /// <param name="commandType">命令字符串类型</param>
        /// <returns>返回受影响的记录数</returns>
        DataSet ExecuteDataSet(string commandText, List<DBParameter> parameters, CommandType commandType);

        /// <summary>
        /// 执行SQL语句,返回受影响的记录数
        /// </summary>
        /// <param name="parameters">参数集合</param>
        /// <param name="commandText">SQL语句或存储过程名称</param>
        /// <returns>返回受影响的记录数</returns>
        int ExecuteNonQuery(List<DBParameter> parameters, string commandText);

        /// <summary>
        /// 执行SQL语句,返回结果的第一行第一列的值
        /// </summary>
        /// <param name="parameters">参数集合</param>
        /// <param name="commandText">SQL语句或存储过程名称</param>
        /// <returns>返回结果的第一行第一列的值</returns>
        object ExecuteScalar(List<DBParameter> parameters, string commandText);

        /// <summary>
        /// 执行SQL语句,返回IDataReader
        /// </summary>
        /// <param name="parameters">参数集合</param>
        /// <param name="commandText">SQL语句或存储过程名称</param>
        /// <returns>返回IDataReader</returns>
        IDataReader ExecuteReader(List<DBParameter> parameters, string commandText);

        /// <summary>
        /// 执行SQL语句,返回DataSet
        /// </summary>
        /// <param name="parameters">参数集合</param>
        /// <param name="commandText">SQL语句或存储过程名称</param>
        /// <returns>返回DataSet</returns>
        DataSet ExecuteDataSet(List<DBParameter> parameters, string commandText);

        #endregion

        /// <summary>
        /// 执行SQL语句，返回IDataReader
        /// </summary>
        /// <param name="commandText">SQL语句或存储过程名称</param>
        /// <param name="parameters">参数集合</param>
        /// <param name="outParameters">返回的参数集合</param>
        /// <returns>返回IDataReader</returns>
        IDataReader ExecuteReader(string commandText, List<DbParameter> parameters, out DbParameterCollection outParameters);
        
        /// <summary>
        /// 执行SQL语句或存储过程，返回IDataReader
        /// </summary>
        /// <param name="commandText">SQL语句或存储过程名称</param>
        /// <param name="commandType">命令字符串类型</param>
        /// <param name="parameters">参数集合</param>
        /// <param name="outParameters">返回的参数集合</param>
        /// <returns>返回IDataReader</returns>
        IDataReader ExecuteReader(string commandText, CommandType commandType, List<DbParameter> parameters, out DbParameterCollection outParameters);
        
        /// <summary>
        /// 执行SQL语句或存储过程，返回IDataReader
        /// </summary>
        /// <param name="commandText">SQL语句或存储过程名称</param>
        /// <param name="parameters">参数集合</param>
        /// <param name="commandType">命令字符串类型</param>
        /// <param name="outParameters">返回的参数集合</param>
        /// <returns>返回IDataReader</returns>
        IDataReader ExecuteReader(string commandText, List<DBParameter> parameters, CommandType commandType, out DbParameterCollection outParameters);
        
        /// <summary>
        /// 执行SQL语句，返回IDataReader
        /// </summary>
        /// <param name="parameters">参数集合</param>
        /// <param name="commandText">SQL语句或存储过程名称</param>
        /// <param name="outParameters">返回的参数集合</param>
        /// <returns>返回IDataReader</returns>
        IDataReader ExecuteReader(List<DBParameter> parameters, string commandText, out DbParameterCollection outParameters);

    }
}
